﻿using Batman.Maintenance.Enums;
using System.Collections.Generic;

namespace Batman.Maintenance.DTO.FormField
{
    public class MaintenanceSelectionFormField : MaintenanceFormField
    {
        public override MaintenanceFormFieldType Type => MaintenanceFormFieldType.Selection;

        public List<MaintenanceLabelValueDTO> Options { get; set; }

        /// <summary>
        /// 优先级高于Options, 获取Options的api地址和映射
        /// </summary>
        public SpecialSource Source { get; set; }
    }

    public class SpecialSource
    {
        /// <summary>
        /// 获取数据的地址
        /// </summary>
        public string Action { get; set; }

        /// <summary>
        /// 映射成为Label的字段名，比如有些数据源返回的不是NameValueDto
        /// </summary>
        public string LabelMap { get; set; }

        public string ValueMap { get; set; }

        public SpecialSource() { }

        public SpecialSource(string action, string labelMap, string valueMap)
        {
            Action = action;

            LabelMap = labelMap;

            ValueMap = valueMap;
        }
    }
}
